/*
 * Project Name: showtao
 * File Name: Product.java
 * Class Name: Product
 *
 * Copyright 2014 showtao.com
 *
 * Licensed under the showtao.com
 *
 * http://showtao.com
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.showtao.front.dto;

import javax.validation.constraints.Max;
import javax.validation.constraints.Size;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.hibernate.validator.constraints.NotBlank;

import com.showtao.front.domain.Product;

/**
 * Class Name: Product Description: TODO
 * 
 * @author
 * 
 */
public class SaveProductDto {

    @NotBlank(message = "{product.id.not.blank}")
    private String id;

    @NotBlank(message = "{product.category.not.blank}")
    @Size(max = 30, message = "{product.category.length.max}")
    private String category;

    @NotBlank(message = "{product.name.not.blank}")
    @Size(min = 1, max = 100, message = "{product.name.length.range}")
    private String name;

    @Max(value = 200, message = "{product.description.length..max}")
    private String description;

    @Max(value = 100, message = "{product.avatarPath.length..max}")
    private String avatarPath;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getAvatarPath() {
        return avatarPath;
    }

    public void setAvatarPath(String avatarPath) {
        this.avatarPath = avatarPath;
    }

    public String toString() {
        return getName();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        } else if (!this.getClass().isInstance(obj)) {
            return false;
        }
        return new EqualsBuilder().append(id, ((Product) obj).getId()).isEquals();
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder().append(id).toHashCode();
    }
}
